package com.ponhu.ea2.goodsCenter.provider.service.impl;

import com.alibaba.nacos.common.utils.CollectionUtils;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.google.common.collect.Lists;
import com.ponhu.ea2.entity.PhCategoryPropertyMd;
import com.ponhu.ea2.entity.PhProperty;
import com.ponhu.ea2.entity.PhPropertyValue;
import com.ponhu.ea2.goodsCenter.provider.mapper.PhPropertyValueMapper;
import com.ponhu.ea2.goodsCenter.provider.service.PhPropertyValueService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

/**
 * <p>
 * 属性值表 服务实现类
 * </p>
 *
 * @author ${author}
 * @since 2021-10-19
 */
@Service
public class PhPropertyValueServiceImpl
        extends ServiceImpl<PhPropertyValueMapper, PhPropertyValue>
        implements PhPropertyValueService {

    /**
     * 根据属性ID集合查询所有属性值集合
     *
     * @param propertyIds
     * @return
     */
    @Override
    public List<PhPropertyValue> getValuesByPropIds(List<Long> propertyIds) {

        if (CollectionUtils.isEmpty(propertyIds)) return Lists.newArrayList();

        LambdaQueryWrapper<PhPropertyValue> queryWrapper = Wrappers
                .lambdaQuery(PhPropertyValue.class)
                .in(PhPropertyValue::getPropertyId, propertyIds);

        return list(queryWrapper);
    }

}
